window.addEventListener('DOMContentLoaded', function() {

    var goback = this.document.querySelector('.goback');
    var tip = this.document.querySelector('.tip');

    var bottom = this.document.querySelector('.bottom');
    var banner = this.document.querySelector('.banner');
    var preTopTip = tip.offsetTop;//tip刚开始的top
    var preTopBo = bottom.offsetTop;//bottom刚开始的top
    console.log(preTopBo);
    //滚动条滚到banner的top=0时tip的top
    var dis = preTopTip - banner.offsetTop;

    this.document.addEventListener('scroll', function() {

  //      console.log(window.pageYOffset);
        if (window.pageYOffset >= 200) {
            tip.style.position = 'fixed';
            tip.style.top = dis + 'px';
            if (window.pageYOffset >= preTopBo) {
                goback.style.display = 'block';
            }
        }else {
            goback.style.display = 'none';
            tip.style.position = 'absolute';
        }
    })
})